<template>
  <div class="SafetyConfirmation">
    <NavBar fixed placeholder title="动火方式" z-index="999" ref="nav">
      <template #left>
        <Icon
          name="arrow-left"
          size="0.53rem"
          color="#000"
          @click="$router.back()"
        />
      </template>
    </NavBar>
    <div class="placeholder"></div>
    <Checkbox-group v-model="result">
      <Checkbox
        class="item"
        v-for="(item, i) in checkBoxList"
        :key="i"
        :name="item.id"
      >
        <span>{{ item.name }}</span>
      </Checkbox>
    </Checkbox-group>

    <div class="btns">
      <Button class="btn" size="small" @click="$router.back()">取消</Button>
      <Button class="btn" type="info" color="#E16712" @click="confirm"
        >确认</Button
      >
    </div>
  </div>
</template>

<script>
import { EquipmentRepairServicePost } from "../../../api/work.js";
import Layout from "components/Layout";
import {
  Checkbox,
  CheckboxGroup,
  NavBar,
  Icon,
  Field,
  Cell,
  Uploader,
  Button,
} from "vant";
export default {
  name: "SafetyConfirmation",

  components: {
    Checkbox,
    CheckboxGroup,
    Uploader,
    Layout,
    NavBar,
    Icon,
    Field,
    Cell,
    Button,
  },

  directives: {},

  data() {
    return {
      result: [],
      checkBoxList: [],
      textarea: "",
    };
  },
  computed: {
    wayName() {
      let arr = [];
      this.checkBoxList.forEach((v) => {
        if (this.result.indexOf(v.id) >= 0) {
          arr.push(v.name);
        }
      });
      return arr.join(",");
    },
  },
  mounted() {
    this.getWhenHotWay();
  },

  methods: {
    async getWhenHotWay() {
      //动火方式
      const { param } = await EquipmentRepairServicePost({
        code: "DgwkFireWork-dfwWay",
        isSeq: 0,
      });
      console.log(param.data);
      this.checkBoxList = param.data;
    },
    confirm() {
      let query = this.$route.query;
      query.way = this.result.join(",");
      query.wayName = this.wayName;
      // return console.log(query);
      this.$router.push({
        path: "JobDetailsNext",
        query,
      });
    },
  },
};
</script>

<style lang="less" scoped>
@import "~@/style/var.less";
.SafetyConfirmation {
  .flex {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  // background-color: #f7f7f9;
  // padding: 30px 0;
  // /deep/.van-nav-bar__content {
  //   background-color: #3982f6;

  //   .van-nav-bar__title {
  //     color: #fff;
  //   }
  // }
  .placeholder {
    width: 100%;
    height: 30px;
    background-color: #f7f7f9;
  }
  .item {
    margin: 40px;
    span {
      font-size: 28px;
      font-family: PingFang SC;
      font-weight: 500;
      color: #333333;
      margin-left: 10px;
    }
  }
  .btns {
    position: absolute;
    bottom: 0px;
    width: 100%;
    padding: 30px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    .btn {
      width: 180px;
      height: 85px;
      border-radius: 5px;
      // margin-left: 50px;
      margin: 0 30px;
    }
  }
  textarea {
    width: 692px;
    height: 157px;
    margin: 10px 0;
    margin-left: 50%;
    padding: 15px;
    transform: translate(-50%);
    border: 1px solid #dddddd;
    font-size: 26px;
    border-radius: 6px;
  }
}
</style>